package com.huangliusong.demo3;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class Man implements BeanNameAware,ApplicationContextAware,InitializingBean,DisposableBean {
    private String name;

    public String getName() {
        System.out.println("【第二步】设置属性getName");
        return name;
    }

    public void setName(String name) {
        System.out.println("【第二步】设置属性setName");
        this.name = name;
    }

    public Man(){
        System.out.println("【第一步】man struct");
    }

    public void setup(){
        System.out.println("【第七步】初始化man");
    }

    public void teardown(){
        System.out.println("【第十一步】销毁man");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("【第三步】设置BeanName:"+s);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("【第四步】了解工厂的信息:"+applicationContext);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("【第六步】属性设置后:");
    }

    public void run(){
        System.out.println("【第九步】执行业务方法:");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("【第十步】执行spring的销毁方法:");
    }
}
